package com.wx.chapter13.homework;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/7/26 - 16:59
 */
public class HomeWork03 {
    public static void main(String[] args) {
        String name = "Han shun Ping";
        printName(name);
    }

    public static void printName(String name) {
        if (name == null) {
            System.out.println("名字不能为空");
            return;//return语句可以直接结束当前程序继续执行
        }
        String[] names = name.split(" ");
        if (names.length != 3) {
            System.out.println("输入的字符串格式不对");
            return;
        }
        String format = String.format("%s,%s,%c", names[2], names[0], names[1].toUpperCase().charAt(0));
        System.out.println(format);
    }
}
